import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Enumeration;

@WebServlet("/hello")
public class HellowServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doPost(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
     /*   System.out.println("你好");
        String contextPath = request.getContextPath();
        System.out.println("虚拟路径: " + contextPath);

        String servletPath = request.getServletPath();
        System.out.println("映射路径:" + servletPath);
        //统一资源标识符
        String requestURI = request.getRequestURI();
        System.out.println(" 统一资源标识符 " + requestURI);
        //统一资源定位符
        StringBuffer requestURL = request.getRequestURL();
        System.out.println("统一资源定位符 = " + requestURL);
//            requestURI范围 >requestURL*/
//        _______________________________
        //根据请求头名称获取一个值
        String header = request.getHeader("conncction");
        System.out.println("header = " + header);
        System.out.println("================");
        //根据请求头名称获取多个值
        Enumeration<String> values = request.getHeaders("accept-encoding");
        while (values.hasMoreElements()){
            String value = values.nextElement();
            System.out.println("value = " + value);

        }
        System.out.println("================");
    //获取请求头名称
        Enumeration<String> headerNames = request.getHeaderNames();
        while (headerNames.hasMoreElements()){
            String name = headerNames.nextElement();
            String value = request.getHeader(name);
            System.out.println(name+","+value);
        }

    }
}
